package com.guigu.msm.controller;
import com.guigu.msm.service.MsmService;
import com.guigu.tms.result.R;
import com.guigu.tms.result.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName:MsmApiController
 * @Description:
 * @Author:longtao
 * @Date:2021/8/6
 * @Version:1.0
 */
@RestController
@RequestMapping("/msm")
@Api(tags = "阿里云发送短信控制层")
public class MsmApiController {
    @Autowired
    private MsmService msmService;

    /**
     * 发送短信验证码
     *
     * @param phone
     * @return
     */
    @GetMapping("send/{phone}")
    @ApiOperation("发送短信")
    public R sendMsm(@PathVariable @ApiParam(name = "phone", value = "手机号") String phone) {
        Boolean flag = msmService.send(phone);
        if (flag) {
            return new R(ResultCode.SUCCESS_CODE, "短信发送成功!");
        } else {
            return new R(ResultCode.ERROR_CODE, "短信发送失败!");
        }
    }

}
